'''
- 回测
- python实现简单回测
- 双移动平均策略
- 海龟策略
'''
import pandas as pd
import numpy as np
import akshare as ak


def gen_stock_data_table(symbol, start_date, end_date):
    print(symbol, start_date, end_date)
    stock = ak.stock_zh_a_hist(symbol=symbol,
                               period="daily",
                               start_date=start_date,
                               end_date=end_date, adjust="hfq")

    print('------原始数据处理---------', stock)
    stock = pd.DataFrame(stock, columns=['日期', '开盘', '最高', '最低', '收盘', '成交量'])
    stock.rename(columns={
        '日期': 'date',
        '开盘': 'open',
        '最高': 'high',
        '最低': 'low',
        '收盘': 'close',
        '成交量': 'volume'
    },
        inplace=True)
    stock.index = pd.DatetimeIndex(stock['date'])

    return {'stock': stock}
